﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace GenesisOne
{
    class Map
    {
        int mapHeight;
        Texture2D[,] tileTable;
        Texture2D grassdirt, dirt;
        Char[,] charTable;

        public Map(int mapHeight, Char[,] charTable)
        {
            this.mapHeight = mapHeight;
            this.charTable = charTable;
        }

        public int MapHeight
        {
            get { return mapHeight; }
            set { this.mapHeight = value; }
        }

        public void Initialize()
        {
            tileTable = new Texture2D[12,10];
        }

        public void Draw(GraphicsDeviceManager graphics, SpriteBatch spriteBatch)
        {
            for (int i = 0; i < 20; i += 1)
            {
                charTable[i, 1] = 'd';
                charTable[i, 0] = 'g';
            }

            //charTable[5, 8] = 'g';


            for (int i = 0; i < charTable.GetLength(0); i++)
            {
                for (int j = 0; j < charTable.GetLength(1); j++)
                {
                    if (charTable[i, j] == 'g')
                    {
                        spriteBatch.Draw(grassdirt, new Vector2(i * 64, graphics.PreferredBackBufferHeight - (j + 1) * 64), Color.White);
                    }

                    else if (charTable[i, j] == 'd')
                    {
                        spriteBatch.Draw(dirt, new Vector2(i * 64, graphics.PreferredBackBufferHeight - (j - 1) * 64), Color.White);
                    }

                }
            }


        }

        public void LoadContent(ContentManager Content)
        {
            grassdirt = Content.Load<Texture2D>("grassdirt");
            dirt = Content.Load<Texture2D>("dirt");
        }
    }
}
